define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'data.store_user/index',
        add_url: 'data.store_user/add',
        edit_url: 'data.store_user/edit',
        delete_url: 'data.store_user/delete',
        export_url: 'data.store_user/export',
        modify_url: 'data.store_user/modify',
        audit_url: 'data.store_user/audit',
        balance_url: 'data.store_user/balance',
        lottery_url: 'data.store_user/lottery',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id',search: false},
                    {field: 'store_type', title: '商户类型',selectList: store_type },
                    {field: 'store_name', title: '商户名称',searchOp:'%*%'},
                    {field: 'address', title: '所在地区',searchOp:'%*%'},
                    {field: 'tel', title: '电话'},
                    {field: 'consumption', title: '消费标准',search:false},
                    {field: 'status', title: '状态 ',selectList: {'-1':'未开启',0: '待审核', 1: '开启中'}},
                    {field: 'create_time', title: '创建时间',search: 'range',},
                    {width: 250, title: '操作', templet: function (d){
                        if(d.status == '0'){
                            return '<a class="layui-btn layui-btn-warm layui-btn-xs" data-open="data.store_user/audit?id='+d.id+'">审核</a>'
                        }else if(d.status == '1'){
                            return '<a class="layui-btn  layui-btn-normal layui-btn-xs" data-open="data.store_user/edit?id='+d.id+'">详情</a>' +
                                '<a class="layui-btn  layui-btn-success layui-btn-xs" data-open="data.store_user/lottery?id='+d.id+'">抽奖设置</a>' +
                                '<a class="layui-btn  layui-btn-danger layui-btn-xs" data-open="data.store_user/balance?id='+d.id+'">充值</a>'
                        }else{
                            return '<a class="layui-btn layui-btn-normal layui-btn-xs" data-open="data.store_user/edit?id='+d.id+'">详情</a>'
                        }
                        }
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        audit: function () {
            ea.listen();
        },
        balance:function (d){
            ea.listen();
        },
        lottery:function (d){
            ea.listen();
        }
    };
    return Controller;
});